#include <stdio.h>
void swap(int* m, int* n) {
    if (m == n)
        return;
    *m = *m + *n;
    *n = *m - *n;
    *m = *m - *n;
}
void selection_sort(int n, int a[n]) {
    if (n < 2)
        return;
    int index = 0;
    for (int i = 1; i < n; i++)
        if (a[index] < a[i])
            index = i;
    swap(&a[index], &a[n - 1]);
    selection_sort(n - 1, a);
}
int main(void)
{
    int n;
    printf("数组的长度：");
    scanf("%d", &n);
    int a[n];
    printf("输入每个元素（整数）：");
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    selection_sort(n, a);
    printf("排序结果：");
    for (int i = 0; i < n; i++)
        printf(" %d", a[i]);
    printf("\n");
    return 0;
}